// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App'
import router from './router'
import vueResource from 'vue-resource'
import "../static/css/common.css"
import store from './store'
import axios from 'axios'

Vue.use(vueResource)
Vue.config.productionTip = false
Vue.prototype.$axios = axios
Vue.use(ElementUI);

// Vue.http.options.emulateHTTP = true;
// Vue.http.options.emulateJSON = true;
router.beforeEach(function (to, from, next) {
  //logged_in变量 记录用户是否登录
  var logged_in=false
  var logged = window.localStorage.getItem('flag')
  if (logged == 'true') {
    logged_in = true
  }
  if (!logged_in && to.matched.some(function (item) {
      return item.meta.login_required
    })) {
    next('/login');
  } else {
    next();
  }

});

var vm=new Vue({
  // el: '#app',
  router,
   store,
  components: { App },
  template: '<App/>'
}).$mount("#app")
